<html>
<head><meta charset="utf-8"><title>rustc_unsafe_specialization_marker · t-libs · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/index.html">t-libs</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html">rustc_unsafe_specialization_marker</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239046189"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker/near/239046189" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html#239046189">(May 17 2021 at 07:40)</a>:</h4>
<p>(not sure if this is libs or lang)</p>
<p>I see the <code>#[rustc_unsafe_specialization_marker]</code> that is intended to be used with <code>min_specialization</code>. I am looking into revamping the <code>Step</code> trait (see <a href="https://github.com/rust-lang/rust/issues/83772">#83772</a>), and believe this marker is appropriate to be used. My question is how are these marker traits used to implement specialization? I'm only familiar with the "normal" specialization, so to speak.</p>



<a name="239049959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker/near/239049959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html#239049959">(May 17 2021 at 08:18)</a>:</h4>
<p>Alright, think I figured it out — just going to try some code to make sure. Should I only use the attribute if I run into a compile error? I'm not familiar with the specifics of when it's needed.</p>



<a name="239056515"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker/near/239056515" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html#239056515">(May 17 2021 at 09:15)</a>:</h4>
<p>If possible a <code>#[rustc_specialization_trait] unsafe trait SpecMarker {}</code> should be used instead. You can then do <code>impl InternalSpecHelperTrait for I where I: Iterator + SpecMarker</code>.</p>



<a name="239056708"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker/near/239056708" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html#239056708">(May 17 2021 at 09:17)</a>:</h4>
<p>The difference being what is known to be sound I presume?</p>



<a name="239057187"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker/near/239057187" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html#239057187">(May 17 2021 at 09:21)</a>:</h4>
<p>Yes, it's sort of explained here: <a href="https://doc.rust-lang.org/stable/nightly-rustc/rustc_typeck/impl_wf_check/min_specialization/index.html#rustc_unsafe_specialization_marker">https://doc.rust-lang.org/stable/nightly-rustc/rustc_typeck/impl_wf_check/min_specialization/index.html#rustc_unsafe_specialization_marker</a></p>
<p>I think the unsafe one is only needed if your marker has a supertrait, which isn't necessary for most specializations.</p>
<p>Also, your PR mentions trustedlen... trustedlen already is a specialization trait, that's not enough to rely on as marker?</p>



<a name="239057338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker/near/239057338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> The 8472 <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html#239057338">(May 17 2021 at 09:22)</a>:</h4>
<p>Ah, step itself isn't an iterator</p>



<a name="239154272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker/near/239154272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jacob Pratt <a href="https://rust-lang.github.io/zulip_archive/stream/219381-t-libs/topic/rustc_unsafe_specialization_marker.html#239154272">(May 17 2021 at 20:24)</a>:</h4>
<p>Yeah I'm doing a PR to change the <code>Step</code> trait, modelling the change after <code>TrustedLen</code>. I speculatively swapped out the attribute with success, so presumably it's fine. Thank you!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>